package yxy.game.pm2.chat.command;

import yxy.apple.logger.Logger;
import yxy.cherry.game.base.bean.ChatBean;
import yxy.cherry.game.base.message.annotation.MessageSource;
import yxy.cherry.game.base.message.annotation.MessageType;
import yxy.cherry.game.base.redis.RedisManager;
import yxy.cherry.game.base.redis.RedisType;
import yxy.game.pm2.bean.area.ChatChannelType;
import yxy.game.pm2.chat.module.ChatHandle;
import yxy.game.pm2.command.Command;
import yxy.game.pm2.message.ChatMessage;
import yxy.game.pm2.message.ChatMessage.ChatChannel;

/** 聊天 聊天内部发送 */
@MessageType(proto = Command.ChatSendInner, classtype = ChatMessage.ChatSendInnerRequest.class)
public class CMD_ChatSendInner extends Command<ChatMessage.ChatSendInnerRequest> {
	protected static Logger logger = Logger.create(CMD_ChatSendInner.class);

	@Override
	public void execute(MessageSource messageSource, ChatMessage.ChatSendInnerRequest request) {
		ChatBean chatBean = ChatBean.get(RedisManager.getInstance().getConnection(RedisType.REDIS_USER));
		if (!chatBean.getInnertoken().equals(messageSource.getTag())) {
			System.err.println("非内部消息");
			return;
		}
		ChatChannel channel = request.getChannel();
		int areaId = request.getAreaId();
		String playerCode = request.getPlayerCode();
		String text = request.getText();

		ChatChannelType channelType = ChatChannelType.forNumber(channel.getNumber());

		ChatHandle.sendInner(playerCode, areaId, channelType, text);

	}

}